<template>
  <div>
  
     <van-form @submit="register">
      <van-field
        v-model="user.phone"
        name="账号"
        label="账号"
        placeholder="账号"
        :rules="[{ required: true, message: '请填写账号' }]"
      />
       <van-field
        v-model="user.nickname"
        name="昵称"
        label="昵称"
        placeholder="昵称"
        :rules="[{ required: true, message: '请填写昵称' }]"
      />
      <van-field
        v-model="user.password"
        type="user.password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button round block style="border:0" type="#82d8cf" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import { Toast } from 'vant';
import {reqregister} from "../../http/http"
export default {
  data() {
    return {
      //1.初始化表单数据
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods:{
    // 2.点了注册按钮 
    register(){
      //发请求
      reqregister(this.user).then(res=>{
       
        if(res.data.code===200){
          //注册成功
          Toast(res.data.msg)
          //跳转到登录
          this.$router.push("/login")
        }
      })
    }
  }
};
</script>

<style>
</style>